﻿@model IEnumerable<Role.Entity.WorkFlow_Info>
@{
    ViewBag.Title = "Index";
}
<h2>
    工作流列表</h2>
<p>
    @Html.ActionLink("建立工作流", "Create")
</p>
@using (Html.BeginForm())
{
    <a href="#" onclick="saveFun();return false;">
        <h3>
            保存</h3>
    </a>
    <table>
        <tr>
            <th>
            </th>
            <th>
                ID
            </th>
            <th>
                前驱节点
            </th>
            <th>
                当前节点
            </th>
            <th>
                后继节点
            </th>
            <th>
                是否为第一个
            </th>
            <th>
                是否为最后一个
            </th>
        </tr>
        @foreach (var item in Model)
        {
            if (item.IsFirstNode)
            { 
            <tr>
                <td colspan="8">
                    <h3>
                        当前工作流：@item.WorkFlow.Name</h3>
                </td>
            </tr>
            }
            <tr>
                <td>
                    @Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
                    @Html.ActionLink("Details", "Details", new { id = item.ID }) |
                    @Html.ActionLink("Delete", "Delete", new { id = item.ID })
                    @Html.Hidden("ID", item.ID)
                </td>
                <td>@item.ID
                </td>
                <td>
                    @Html.TextBox("PrevNode", item.PrevNode, new { style = "width:30px" })
                    @(item.PrevNodeEntity == null ? string.Empty : item.PrevNodeEntity.Name)
                </td>
                <td>
                    <b style="color: Red">@item.Name</b>
                </td>
                <td>
                    @Html.TextBox("NextNode", item.NextNode, new { style = "width:30px" })
                    @(item.NextNodeEntity == null ? string.Empty : item.NextNodeEntity.Name)
                </td>
                <td>@item.IsFirstNode
                </td>
                <td>@item.IsEndNode
                </td>
            </tr>
        }
    </table>
}
<script>
    function saveFun() {
        $.ajax({
        url:"@Url.Action("Save", "WorkFlow")",
        type:"POST",
        data:$("form").serialize(),
        success:function(data){
        
        }
        });
    }
</script>
